<template>
 
      <div @click="listen">
        监听
      </div>
   
</template>
<script>


export default {
  created() {
    console.log("this.$socket");
  //  console.log(this.$socket);
   // console.log(this.$socket.emit);
    // this.$socket.emit("test", "val");
    //  this.$socket.on("receiveMsg", data => {
    //       console.log(data);
    //  });
  },
  methods: {
    listen() {
    //  console.log('this.$socket.connect',this.$socket.connect) 
    //  this.$socket.connect('ws://127.0.0.1:3002/conn')
 this.$socket.on("receiveMsg", data => {
          console.log(data);
     });
  axios.get('/api/log/listen')
    .then(r=>{
     
        
   })
    //   console.log("sss");
    }
  },
  data() {
    return {};
  },
  sockets: {
    connect: function() {
      console.log("socket connected");
    },
    customEmit: function(val) {
      console.log(
        'this method was fired by the socket server. eg: io.emit("customEmit", data)'
      );
    }
  },
  components: {}
};
</script>